home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / fixes / delp126 / prog2 / conj2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-19  |  2.0 KB  |  68 lines

  1. unit Conj2;
  2. { PC Plus sample Delphi program. A simple French verb conjugator - mark 2 }
  3.  
  4. interface
  5.  
  6. uses
  7.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  8.   Forms, Dialogs, StdCtrls;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     ListBox1: TListBox;
  13.     Edit1: TEdit;
  14.     Label1: TLabel;
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.DFM}
  29.  
  30. procedure TForm1.Button1Click(Sender: TObject);
  31. var                  { --- Declare 3 string variables --- }
  32.   verb,              { the verb specified by the user     }
  33.   verbStem,          { the verb minus its 2-letter ending }
  34.   verbEnd : string;  { the 2-letter ending                }
  35. begin
  36.   verb := Edit1.Text;
  37.        { check that the user has entered something... }
  38.   if verb = '' then
  39.      Caption := 'You must enter a verb!'
  40.   else
  41.   { BEGIN BLOCK # 1 - if verb is not '' }
  42.   begin {... if so, then                              }
  43.         { find the stem and the ending of the verb    }
  44.     verbStem := copy( verb, 1, length(verb)-2 );
  45.     verbEnd  := copy( verb, length(verb) -1, 2 );
  46.     Caption  := 'This is an ' + verbEnd + ' verb.';
  47.         { if this isn't an ER verb, show error msg... }
  48.     if LowerCase( verbEnd ) <> 'er' then
  49.        Caption := 'You must enter an ER verb!'
  50.     else
  51.     { BEGIN BLOCK #2 - if this is an ER verb }
  52.     begin {... otherwise, display verb conjugation    }
  53.       ListBox1.Items.Add('Je ' + verbStem + 'e');
  54.       ListBox1.Items.Add('Tu ' + verbStem + 'es' );
  55.       ListBox1.Items.Add('Il ' + verbStem + 'e' );
  56.       ListBox1.Items.Add('Elle ' + verbStem + 'e' );
  57.       ListBox1.Items.Add('Nous ' + verbStem + 'e' );
  58.       ListBox1.Items.Add('Vous ' + verbStem + 'ez' );
  59.       ListBox1.Items.Add('Ils ' + verbStem + 'ent');
  60.       ListBox1.Items.Add('Elles ' + verbStem + 'ent');
  61.     end;
  62.     { END BLOCK #2 }
  63.   end;
  64.   { END BLOCK # 1 }
  65. end;
  66.  
  67. end.
  68.